<template>
  <div>

  </div>
</template>
<script>
import { utilJs } from "@/utils/common.js"
export default {
  name: "ActivityEmpty",
  data() {
    return {
      from: 0,
      activityId: 0,
      channel: 'activity', // 来源 活动还是约课
      rsId: null
    }
  },
  created() {
  },
  methods: {
    reservationSign() { // 约课签到
      let $this = this;
      utilJs.postMethod(global.apiurl + 'reservations/signUp',
        {
          rtId: this.activityId,
          rsId: this.rsId
        },
        function (res) {
          $this.$routerGo($this, "replace", { path: `/activity/signResult`, query: { groupName: res.groupName, channel: $this.channel, from: res.retError, activityId: $this.activityId, msg: res.msg, rsId: $this.rsId } })
        }
      );
    },
    activitySign() { // 活动签到
      let $this = this;
      utilJs.getMethod(global.apiurl + 'activities/signedActivity/' + this.activityId, function (res) {
        $this.from = res.from
        $this.activityId = res.activityId
        $this.$routerGo($this, "replace", { path: `/activity/signResult`, query: { groupName: res.groupName, channel: $this.channel, from: $this.from, activityId: $this.activityId } })
      })
    }
  },
  activated() {
    this.activityId = this.$route.query.activityId;
    this.channel = this.$route.query.channel ? this.$route.query.channel : 'activity';
    this.rsId = this.$route.query.rsId; // 约课的场次id， 约课签到用到
    this.channel == 'reservation' ? this.reservationSign() : this.activitySign();
  }
}
</script>

